<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>定时任务</title>
	<link rel="stylesheet" href="/static/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/phcrontab.css">
    <script src="/static/jquery.min.js"></script>
    <script src="/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>	
</head>
<body>
	<div class="container-fluid">
		<div class="setbox bgw mtb15">
            <div class="title c6 plr15">
                <h3 class="f16">添加计划任务</h3>
            </div>
            <div class="setting-con ptb20">
                <div class="clearfix plan">
                    <span class="typename c4 pull-left f14 text-right mr20">任务类型</span>
                    <div class="dropdown planjs pull-left mr20">
                        <button class="btn btn-default dropdown-toggle" type="button" id="excode" data-toggle="dropdown" style="width:auto" aria-expanded="false">
			        	<b val="toShell">Shell脚本</b>
			        	<span class="caret"></span>
			    		</button>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="excode">
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="toShell">Shell脚本</a></li>
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="site">备份网站</a></li>
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="database">备份数据库</a></li>
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="logs">日志切割</a></li>
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="rememory">释放内存</a></li>
	                        <li><a role="menuitem" tabindex="-1" href="javascript:;" value="toUrl">访问URL</a></li>
                        </ul>
                    </div>
                    <span class="planSign"><i>*</i>任务类型包含以下部分：Shell脚本、备份网站、备份数据库、日志切割、释放内存、访问URL</span>
                </div>
                <div class="clearfix plan">
                    <span class="typename c4 pull-left f14 text-right mr20">任务名称</span>
                    <div class="planname pull-left"><input type="text" name="name" class="bt-input-text"></div>
                </div>
                <div class="clearfix plan">
                    <span class="typename c4 pull-left f14 text-right mr20">执行周期</span>
                    <div class="dropdown plancycle pull-left mr20">
                        <button class="btn btn-default dropdown-toggle" type="button" id="cycle" data-toggle="dropdown" style="width:94px" aria-expanded="false">
				        <b val="day">每天</b>
				        <span class="caret"></span>
				    	</button>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="cycle">
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="day">每天</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="day-n">N天</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="hour">每小时</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="hour-n">N小时</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="minute-n">N分钟</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="week">每星期</a>
                                </li>
                                <li><a role="menuitem" tabindex="-1" href="javascript:;" value="month">每月</a>
                                </li>
                        </ul>
                    </div>
                    <div id="ptime" class="pull-left"><div class="plan_hms pull-left mr20 bt-input-text">					<span><input type="number" name="hour" value="1" maxlength="2" max="23" min="0"></span>					<span class="name">小时</span>					</div><div class="plan_hms pull-left mr20 bt-input-text">					<span><input type="number" name="minute" value="30" maxlength="2" max="59" min="0"></span>					<span class="name">分钟</span>					</div></div>
                </div>
                <div class="clearfix plan">
                        <span class="typename controls c4 pull-left f14 text-right mr20">脚本内容</span>
                        <div id="implement" style="line-height:34px"><textarea class="txtsjs bt-input-text" name="sBody"></textarea></div>
                </div>
                <div class="clearfix plan">
                        <div class="bt-submit plan-submit" onclick="planAdd()">添加任务</div>
                </div>
                <ul class="help-info-text c7 ptb15 mlr20">
                        <li>当添加完备份任务，应该手动运行一次，并检查备份包是否完整</li>
                        <li>磁盘容量不够、数据库密码错误、网络不稳定等原因，可能导致数据备份不完整</li>
                </ul>
            </div>
            <form id="set-Config" action="/crontab?action=AddCrontab" enctype="multipart/form-data" method="post" style="display: none;">
                    <input type="text" name="name" value="">
                    <input type="text" name="type" value="">
                    <input type="number" name="where1" value="">
                    <input type="number" name="hour" value="">
                    <input type="number" name="minute" value="">
                    <input type="text" name="week" value="">
                    <input type="text" name="sType" value="">
                    <textarea name="sBody"></textarea>
                    <input id="sFile" type="file" name="sFile" value="">
                    <input id="sName" type="text" name="sName" value="">
                    <input id="backupTo" type="text" name="backupTo" value="localhost">
                    <input id="urladdress" type="text" name="urladdress" value="">
                    <input type="number" name="save" value="">
                    <input type="submit">
            </form>
        </div>


		<div class="setbox bgw mtb15">
	        <div class="title c6 plr15">
	            <h3 class="f16">任务列表</h3>
	            <span id="allDelete" style="float: right;display: none;">
	                    <button onclick="allDeleteCron();" class="btn btn-default btn-sm">删除选中</button>
	            </span>
	        </div>
	        <div class="setting-con divtable pd15">
                <table class="table table-hover">
                    <thead>
                        <tr>
	                        <th width="30px"><input onclick="checkSelect();" type="checkbox" id="setBox"></th>
	                        <th>任务名称</th>
	                        <th>周期</th>
	                        <th>执行时机</th>
	                        <th>添加时间</th>
	                        <th width="190">操作</th>
                        </tr>
                    </thead>
                        <tbody id="cronbody">
                        	<tr>
                        		<td><input type="checkbox" onclick="checkSelect();" title="释放内存" name="id" value="1"></td>
                        		<td>释放内存</td>
                        		<td>每天</td>
                        		<td>每天, 3点15分 执行</td>
                        		<td>2018-10-30 17:07:23</td>
                        		<td><a href="javascript:StartTask(1);" class="btlink">执行</a>|<a href="javascript:OnlineEditFile(0,'/www/server/cron/8069526a8a484cefbf8dc8d31934d815');" class="btlink">脚本</a>|<a href="javascript:GetLogs(1);" class="btlink">日志</a>|<a href="javascript:planDel(1 ,'释放内存');" class="btlink">删除</a></td>
                        	</tr>
                        </tbody>
                </table>
	        </div>
        </div>

	</div>
	<script src="/static/lan.js?date=20180124"></script>
	<script src="/static/crontab.js?date=20180808"></script>
	<script type="text/javascript">
	        toWeek();
	        toHour();
	        toMinute();
	        toShell();
	        getCronData();
	</script>
	<script type="text/javascript">
                $("#setBox").click(function() {
                        if($(this).prop("checked")){
                                $("input[name=id]").prop("checked", true)
                        }else{
                                $("input[name=id]").prop("checked", false)
                        }
                });

                function planAdd(){
                	$.post('/crontab/to/', {fun: '1'}, function(data) {
                		alert(data);
                	});
                }
        </script>
</body>
</html>